package com.yinp.proapp.utils;

import com.tencent.mmkv.MMKV;

import static com.yinp.proapp.constant.SpConstants.SP_NAME;

public class SpUtils {
    private static MMKV kv = MMKV.mmkvWithID(SP_NAME, MMKV.MULTI_PROCESS_MODE);

    /**
     * 保存boolean常量
     */
    public static void saveValue(boolean value, String key) {
        kv.encode(key, value);
    }

    /**
     * 保存boolean常量
     */
    public static boolean getValue(String key, boolean defValue) {
        return kv.decodeBool(key, defValue);
    }

    /**
     * 保存String常量
     */
    public static void saveValue(String value, String key) {
        kv.encode(key, value);
    }

    /**
     * 保存boolean常量
     */
    public static String getValue(String key, String defValue) {
        return kv.decodeString(key, defValue);
    }

    /**
     * 保存Int常量
     */
    public static void saveValue(int value, String key) {
        kv.encode(key, value);
    }

    /**
     * 保存boolean常量
     */
    public static int getValue(String key, int defValue) {
        return kv.decodeInt(key, defValue);
    }
}
